---格挡
---@class BuffEffect53 : BaseBuffEffect
BuffEffect53 = ClientFight.CreateClass("BuffEffect53", ClientFight.BaseBuffEffect)
local t = BuffEffect53
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};

    local result =  parameters[3];
    if (not result:isDamage()) then
    return IBuffEffect.FAIL;
    end
    if (not AttackUtils.isDamage(result.state)) then
    return IBuffEffect.FAIL;
    end
    local calculatorType = buff.buffBean.f_BuffEffectValue[1];
    local calculateAttrType = buff.buffBean.f_BuffEffectValue[2];
    local modifiedRatio = buff.buffBean.f_BuffEffectValue[3] * buff.overlay;
    local calculator = calculatorType == 0 and buff.source or buff.target;

    local attrValue = FighterAttributeManager.getFightAttr(calculator, calculateAttrType);
    local value = calcRatio(attrValue, modifiedRatio);


    result.damage = Math.max(result.damage - value, 0);
    local commandInfo = ReportManager.additionalStateToJsonString(fight, buff.target, FighterAdditionalState.BLOCK)
    table.insert(fight.actions,commandInfo);
    FightManager.playActions(commandInfo);
    SkillRoleMgr.savePathFile( string.format("[%s][EFFECT]%s触发%s格挡伤害%s",
    fight.frame, buff.target.fighterId, buff.modelId,value
    ));
    return ClientFight.BaseBuffEffect.action(self,fight, buff, parameters);
end

t.New()